﻿#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include "normalization.h"



__global__ void resizeImage(const unsigned char* src, int src_pitch, float* dst, int dst_pitch)
{
    int dstX = blockIdx.x;  // 目标图像的 x 坐标
    int dstY = blockIdx.y;  // 目标图像的 y 坐标
    int dstZ = threadIdx.x;

    int dstIndex0 = dstZ + dstX * 3 + dstY * dst_pitch * 3;
    int srcIndex0 = dstZ + dstX * 3 + dstY * src_pitch * 3;

    dst[dstIndex0] = (float)src[srcIndex0] / 255.0;


}
void resize2GPU(const cudaPitchedPtr src, const cudaPitchedPtr dst)
{
    dim3 blocks(src.pitch, src.xsize);
    dim3 threads(3);
    unsigned char* SrcPtr = (unsigned char*)src.ptr;
    float* DstPtr = (float*)dst.ptr;
    resizeImage << < blocks, threads >> > (SrcPtr, src.pitch, DstPtr, dst.pitch);
    cudaDeviceSynchronize();

}



